/////////////////////////////////////////////////////////////
// File Name	:	"CCamera.H"
//
// Author Name	:	Brandon Layton (BL)
//
// Purpose:		:	Moves the game screen around
/////////////////////////////////////////////////////////////
#pragma once

#include "../tools/MathHelper.h"
#include <list>
#include <vector>
#include "../Messaging/EventSystem.h"
using std::list;
using std::vector;

class CBase;

struct PositionTimePair
{
	vector2D	m_vPosition1;
	vector2D	m_vPosition2;

	float		m_fTime;
};

class CCamera : public IListener
{
	
	//Position of the camera
	vector2D	m_vPosition;

	//Path following stuff
	float		m_fTimer;
	float		m_fTravelTime;
	list<PositionTimePair> m_vPathPositions;
	bool		m_bMovingAlongPath;
	PositionTimePair * m_CurrentPath;

	//Following object stuff
	CBase *		m_pFollowingObject;
	bool		m_bFollowingObject;
	int			m_nViewPortWidth;
	int			m_nViewPortHeight;
	int			m_nHalfHeight;
	int			m_nHalfWidth;

	RECT		m_rBounds;

public:
	CCamera(int nWidth, int nHeight);
	~CCamera();

	void SetBounds(RECT rect) { m_rBounds = rect; }
	vector2D GetPosition() { return m_vPosition; }
	//Moves the camera from one point to the other over a period of time
	void MoveAlongPath(vector2D vStartPosition, vector2D vEndPosition, float fTimeToTravel);
	//Move the camera along a series of positions over given time periods
	void MoveAlongPath(vector<vector2D> vPositions, vector<float> vTimes);
	//Add a position for the camera to go to
	void AddPointAlongPath(vector2D vDestPosition, float fTime);

	void Update(float dt);

	//Stop moving the camera along a path
	void StopPath();

	//Attaches the camera a base object to follow
	void AttachToObject(CBase * pObject);

	//stop follow 
	void FreeFromObject();

	bool HandleEvent(CEvent * pEvent);
};